﻿
Partial Class Admin_ErrorLog
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        rptrList.DataSource = ErrorLog.GetRecent(50)
        rptrList.DataBind()
    End Sub
    Protected Overrides Sub OnError(ByVal e As System.EventArgs)
        'MyBase.OnError(e)
        'EAT THE ERRORS HERE
    End Sub
    Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If ErrorLog.ClearError(New Guid(DirectCast(sender, ImageButton).CommandArgument.ToString)) Then
            Response.Redirect(Request.Url.OriginalString)
        Else
            lblMessage.Text = "Error, unable to clear error"
        End If
    End Sub
    Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If ErrorLog.Delete(New Guid(DirectCast(sender, ImageButton).CommandArgument.ToString)) Then
            Response.Redirect(Request.Url.OriginalString)
        Else
            lblMessage.Text = "Error, unable to delete error"
        End If
    End Sub

    Protected Sub rptrList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptrList.ItemDataBound
        If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then
            Dim er As ErrorLog = CType(e.Item.DataItem, ErrorLog)
            DirectCast(e.Item.FindControl("btnDelete"), ImageButton).CommandArgument = er.ErrorID.ToString
            DirectCast(e.Item.FindControl("btnClear"), ImageButton).CommandArgument = er.ErrorID.ToString
        End If
    End Sub

End Class
